﻿/********************************************************************************************************************
* Author:	Christos Polydorou																						*
* Email:	std04237@di.uoa.gr																						*
* Purpose:	This script is used in order to create the "Entities" table	that holds all entities.					*
********************************************************************************************************************/

CREATE TABLE [dbo].[Entities]
(
	ID bigint PRIMARY KEY NOT NULL IDENTITY(1,1),								/* The id of the entity */ 
	Category bigint NOT NULL,													/* The category it bellongs to */
	Name nvarchar(50) NOT NULL,													/* The name of the entity */
	IsApproved	int NULL,
	FOREIGN KEY(Category) REFERENCES Categories(ID),
	CONSTRAINT UniqueNameForEntityInCategory UNIQUE (Name,Category)				/* The name of the entity in a category must be unique */
)
